<?php
namespace app\model;

use sqhlib\Hanzi\HanziConvert;
use think\Model;

class Dictionary extends Model {
    protected $autoWriteTimestamp = false;
    protected $createTime = false;
    protected $updateTime = false;

    public static function convert_to_simplified_char($char) {
        return HanziConvert::convert($char);
    }

    public static function find_pron($pron) {
        return substr($pron, 0, mb_strlen($pron) - 1);
    }

    public static function find_tone($pron) {
        return intval(substr($pron, mb_strlen($pron) - 1, 1));
    }

    public static function improved_tone($original_tone) {
        switch ($original_tone) {
            case 1:
            case 2:
                return 4;
            case 3:
            case 5:
                return 3;
            case 6:
                return 2;
            case 4:
                return 1;
        }
        return NULL;
    }
}